<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!--List all of complaint orders-->
            <div class="table-outer">
                <h1 class="center-font">所有投诉订单</h1><br>
               	<c:if test="${orders.size() == 0}">
               		<div class="out-container">
						<div class="boo-wrapper">
							<div class="boo">
								<div class="face"></div>
							</div>
							<div class="shadow"></div>
							<h1>恭喜，您还没有投诉订单~</h1>
						</div>
					</div>
               	</c:if>
                <c:forEach var="o" items="${orders}">
                <table class="table table-striped">
                    <thead class="yellow-bg">
                    <tr>
                        <th colspan="2">下单时间：${o.startTime}</th>
                        <th>客户号码：${o.client.cTel}</th>
                        <c:if test="${o.oStatus == \"2\"}">
                        	<th>订单状态：已接单</th>
                        </c:if>
                        <c:if test="${o.oStatus == \"3\"}">
                        	<th>订单状态：已确认收货</th>
                        </c:if>
                        <c:if test="${o.oStatus == \"4\"}">
                        	<th>订单状态：已拒绝</th>
                        </c:if>
                    </tr>
                    <tr>
                    	<th colspan="2">配送地址：${o.client.cLocation}</th>
                    	<th class="toggle" onclick="showOrhidd(${o.oId})" style="background-color:#fffff0;">查看详情
                    		<span type="button" id="o${o.oId}" style="margin-left:15px;"><i class="fa fa-lg fa-angle-down fa-angle-double-up"></i></span>
                    	</th>
                    	<th><button id="complain-btn" type="button" class="btn btn-common" data-toggle="modal" data-target="#myModal" 
                    	onclick="complain('${o.oId}','${o.complaint}')">投诉内容及结果</button></th>
					</tr>
					
                    </thead>
                    <tbody class="form" id="form${o.oId}" style="display:none;">
                    <tr>
						<td colspan="4"><h4><b>订单菜品列表</b></h4></td>
                    </tr>
                    <tr>
                        <td>菜品名称</td>
                        <td>单价/&yen;</td>
                        <td>数量</td>
                        <td>价格/&yen;</td>
                    </tr>
                    <c:forEach var="f" items="${o.foodlist}">
	                    <tr>
	                        <td>${f.fName }</td>
	                        <td>${f.fPrice }</td>
	                        <td>${f.num }</td>
	                        <td>${f.fPrice * f.num}</td>
	                    </tr>
	                    <c:set value="${sum + f.fPrice * f.num}" var="sum" />
                    </c:forEach>
                    	<tr>
	                    	<td style="font-weight:bolder;">总计：</td>
	                    	<td colspan="2"></td>
	                    	<td class="order-sum">${sum}</td>
	                    	<c:set value="0" var="sum" />
	                    </tr>
                    </tbody>
                </table>
                </c:forEach>
            </div>
            
            <!-- Modal -->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			  <div class="modal-dialog" role="document" style="margin-top: 150px;">
			    <div class="modal-content">
			      <div class="modal-header yellow-header">
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			        <h4 class="modal-title" id="myModalLabel">投诉信息及处理结果</h4>
			      </div>
			      <div class="modal-body" >
			        <h4>处理结果：<span id="comp-result"></span></h4>
			        <p id="comp-info"></p>
			      </div>
			      <div class="modal-footer">
			        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			      </div>
			    </div>
			  </div>
			  
			  
			  <script type="text/javascript">
			  
				 function complain(oid,info){
					 $.ajax({
			              url:"compResult",
			              type:"post",
			              data:{oId:oid},
			              success:function(d){
			            	  if(d.status){
			            		  $("#comp-info").html(info);
			            		  if(d.data == 1){
			            			  $("#comp-result").html("未处理");
			            		  }else if(d.data == 2){
			            			  $("#comp-result").html("驳回投诉");
			            		  }else if(d.data == 1){
			            			  $("#comp-result").html("扣除押金");
			            		  }else{
			            			  $("#comp-result").html("商家被拉黑");
			            		  }
			            		  
			            	  }
			              }
			          })
				 }
				 
				 function showOrhidd(oid){
						$('#o'+oid).children('i').toggleClass('fa-angle-down');
						$('#form'+oid).animate({
				            height: "toggle",
				            'padding-top': 'toggle',
				            'padding-bottom': 'toggle',
				            opacity: "toggle"
				        }, "normal");
					}
			  
			  </script>
			  
</div>

